﻿<phone:PhoneApplicationPage  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:telerikPrimitives="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Primitives" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:viewmodel="clr-namespace:DDU.ViewModel;assembly=DDU.ViewModel"
    xmlns:Converters="clr-namespace:DDU.Converters;assembly=DDU.Converters"
    xmlns:UX="clr-namespace:DDU.UX;assembly=DDU.UX"
    x:Class="DDU.Curriculum.Views.BookGalleryView"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False" >
    <phone:PhoneApplicationPage.Resources>
        <Converters:StreamToImageConverter x:Key="StreamToImageConverter" />
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <Converters:EnumTranslateConverter x:Key="EnumTranslateConverter" />
    </phone:PhoneApplicationPage.Resources>
    <Grid x:Name="LayoutRoot">
    	<Grid.Background>
    		<ImageBrush Stretch="Fill" ImageSource="/Assets/back.png"/>
    	</Grid.Background>
        <Grid.DataContext>
            <viewmodel:BookGalleryViewModel/>
        </Grid.DataContext>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <ListBox ItemsSource="{Binding Path=ItemsOfBooks}">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <telerikPrimitives:RadWrapPanel></telerikPrimitives:RadWrapPanel>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="12,0,0,12" Tag="{Binding Path=Guid}" Tap="GotoEditView" >
                            <Image Source="{Binding Path=Stream, Converter={StaticResource StreamToImageConverter}}" Width="210" Height="210" Stretch="Fill"/>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Foreground="{StaticResource PhoneChromeBrush}" Text="{Binding Title}" VerticalAlignment="Bottom"/>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

            <Grid Grid.Row="1" Margin="0,12">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Rectangle Height="1" Margin="12,0" Fill="{StaticResource PhoneForegroundBrush}"/>
                <Rectangle Height="1" Margin="12,0" Fill="{StaticResource PhoneForegroundBrush}" Grid.Column="2"/>

                <UX:UXPathButton IconPath="{StaticResource PATH_ICON_PLAY}" Command="{Binding PlayCommand}" Grid.Column="1"/>
            </Grid>
        </Grid>
        
        <Grid Grid.RowSpan="3" Visibility="{Binding Path=SlideVisibility}">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>

            <telerikPrimitives:RadSlideView x:Name="slideView" ItemsSource="{Binding ItemsOfBooks}" Grid.RowSpan="2" SelectedItem="{Binding Mode=TwoWay, Path=CurrentBookItem}">
                <telerikPrimitives:RadSlideView.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Image Height="800" Width="480" Stretch="Fill" Source="{Binding Path=Stream, Converter={StaticResource StreamToImageConverter}}"/>
                        </Grid>
                    </DataTemplate>
                </telerikPrimitives:RadSlideView.ItemTemplate>
            </telerikPrimitives:RadSlideView>
            
            <StackPanel Visibility="{Binding Path=ShowDetails, Converter={StaticResource BooleanToVisibilityConverter}}" VerticalAlignment="Bottom" Margin="12">
                <TextBlock Style="{StaticResource PhoneTextTitle3Style}" Text="名称"/>
                <TextBlock Style="{StaticResource PhoneTextAccentStyle}" Text="{Binding Path=CurrentBookItem.Title}" />
                <TextBlock Style="{StaticResource PhoneTextTitle3Style}" Text="任课老师"/>
                <TextBlock Style="{StaticResource PhoneTextAccentStyle}" Text="{Binding Path=CurrentBookItem.Teacher}" />
                <TextBlock Style="{StaticResource PhoneTextTitle3Style}" Text="图书出版号(ISBN)"/>
                <TextBlock Style="{StaticResource PhoneTextAccentStyle}" Text="{Binding Path=CurrentBookItem.ISBN}" />
                <TextBlock Style="{StaticResource PhoneTextTitle3Style}" Text="定价"/>
                <TextBlock Style="{StaticResource PhoneTextAccentStyle}" Text="{Binding Path=CurrentBookItem.Price,StringFormat=\{0:C\}}" />
            </StackPanel>

            <Grid Grid.Row="1" Margin="12">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Rectangle Height="1" Margin="12,0" Fill="{StaticResource PhoneForegroundBrush}"/>
                <Rectangle Height="1" Margin="12,0" Fill="{StaticResource PhoneForegroundBrush}" Grid.Column="2"/>

                <StackPanel Orientation="Horizontal" Grid.Column="1">
                    <UX:UXCheckBox IconPath="{StaticResource PATH_ICON_DETAIL}" IsChecked="{Binding ShowDetails,Mode=TwoWay}" />
                    <Rectangle Width="12"/>
                    <UX:UXPathButton IconPath="{StaticResource PATH_ICON_STOP}" Padding="14" Command="{Binding StopCommand}" />
                </StackPanel>
            </Grid>
        </Grid>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{StaticResource IDS_APP_NAME}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle2Style}">
                <Run Text="{Binding SemesterInfo.EducationLevel, Converter={StaticResource EnumTranslateConverter}}"/>
                <Run Text=" "/>
                <Run Text="{Binding SemesterInfo.Grade, Converter={StaticResource EnumTranslateConverter}}"/>
            </TextBlock>
        </StackPanel>
        
    </Grid>
 
    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>
